package com.caojin.propertyInjector.propertyResolver;

import java.io.InputStream;
import java.util.Properties;

import com.caojin.propertyInjector.locationResolver.ClassPathLocationResolver;
import com.caojin.propertyInjector.locationResolver.LocationResolver;
import com.caojin.util.PropertiesUtil;

/**
 * 普通的属性配置文件解析器
 * 
 * @author caojin
 */
public class BasePropertiesResolver extends PropertiesResolver {

	public BasePropertiesResolver() {
		//默认使用类路径解析器
		this.locationResolver = new ClassPathLocationResolver();
		//默认使用缓存
		this.useCache = Boolean.TRUE;
	}

	public BasePropertiesResolver(LocationResolver locationResolver,
			boolean useCache) {
		this.locationResolver = locationResolver;
		this.useCache = useCache;
	}

	@Override
	protected Properties getPropertiesFromLocation() {
		InputStream in = locationResolver.getInputStream();
		return PropertiesUtil.loadProperties(in);
	}
}
